const mongoose = require('mongoose')

// 1. 连接数据库
const db = mongoose.createConnection(
  // 'mongodb://localhost:27017/demo'
  'mongodb://用户名:密码@localhost:27017/demo?authSource=admin',
  { useNewUrlParser: true, useUnifiedTopology: true },
  err => {
    if (err) {
      return console.log('数据库连接失败：', + err)
    }
    console.log('数据库连接成功！')
  }
)

module.exports = db